home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.2)
-
- '''Exception Handling
-
- Exceptions
-
- \t To better support COM exceptions, the framework allows for an instance to be
- \t raised. This instance may have a certain number of known attributes, which are
- \t translated into COM exception details.
- \t
- \t This means, for example, that Python could raise a COM exception that includes details
- \t on a Help file and location, and a description for the user.
- \t
- \t This module provides a class which provides the necessary attributes.
-
- '''
- import sys
- import pythoncom
-
- class COMException(pythoncom.com_error):
- '''An Exception object that is understood by the framework.
- \t
- \tIf the framework is presented with an exception of type class,
- \tit looks for certain known attributes on this class to provide rich
- \terror information to the caller.
-
- \tIt should be noted that the framework supports providing this error
- \tinformation via COM Exceptions, or via the ISupportErrorInfo interface.
-
- \tBy using this class, you automatically provide rich error information to the
- \tserver.
- \t'''
-
- def __init__(self, description = None, scode = None, source = None, helpfile = None, helpContext = None, desc = None, hresult = None):
- '''Initialize an exception
- \t\t**Params**
-
- \t\tdescription -- A string description for the exception.
- \t\tscode -- An integer scode to be returned to the server, if necessary.
- \t\tThe pythoncom framework defaults this to be DISP_E_EXCEPTION if not specified otherwise.
- \t\tsource -- A string which identifies the source of the error.
- \t\thelpfile -- A string which points to a help file which contains details on the error.
- \t\thelpContext -- An integer context in the help file.
- \t\tdesc -- A short-cut for description.
- \t\thresult -- A short-cut for scode.
- \t\t'''
- if not scode:
- pass
- scode = hresult
- if scode and scode != 1:
- if scode >= -32768 and scode < 32768:
- scode = -2147024896 | scode & 65535
-
-
- self.scode = scode
- if not description:
- pass
- self.description = desc
- if scode == 1 and not (self.description):
- self.description = 'S_FALSE'
- elif scode and not (self.description):
- self.description = pythoncom.GetScodeString(scode)
-
- self.source = source
- self.helpfile = helpfile
- self.helpcontext = helpContext
- pythoncom.com_error.__init__(self, scode, self.description, None, -1)
-
-
- def __repr__(self):
- return '<COM Exception - scode=%s, desc=%s>' % (self.scode, self.description)
-
-
- Exception = COMException
-
- def IsCOMException(t = None):
- if t is None:
- t = sys.exc_info()[0]
-
-
- try:
- return issubclass(t, pythoncom.com_error)
- except TypeError:
- return t is pythoncon.com_error
-
-
-
- def IsCOMServerException(t = None):
- if t is None:
- t = sys.exc_info()[0]
-
-
- try:
- return issubclass(t, COMException)
- except TypeError:
- return 0
-
-
-